package com.cqemme.messageservice.receive;



import com.cqemme.comm.constraint.MqNames;
import com.cqemme.comm.po.NoteMessage;
import com.cqemme.comm.utils.JackSonUtils;
import com.cqemme.messageservice.service.NoteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 短信接收者
 */
@Component
@Slf4j
public class NoteReceiver {

    @Autowired
    private NoteService noteService;

    @RabbitListener(queues = MqNames.SEND_MESSAGE_MQ)
    public void Receiver(String content){
//        System.out.println("消费发短信");
//        System.out.println(content);
        try {
            NoteMessage noteMap=JackSonUtils.strToBean(content, NoteMessage.class);
            noteService.sendNote(noteMap);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
